<?php
class Peliculas extends CI_Controller{

	public function pelicula($id){
		$this->load->model('Peliculas_model','peli');
		$this->load->model('Actors_model',"actors");
		$data['pelicula']=$this->peli->get_pelicula($id);
		$data['actors']=$this->actors->get_actors_peli($id);

		if(!is_array($data['pelicula'])){
			$data['title']="No se ha encontrado";
			$this->load->view('templates/header',$data);
			$this->load->view('peliculas/404',$data);
			$this->load->view('templates/footer');
		}

		$data['title']=$data['pelicula']['titulo'];

		$this->load->view('templates/header',$data);
		$this->load->view('peliculas/pelicula',$data);
		$this->load->view('templates/footer');
	}

	public function peliculas_genero($id_genero,$orderby="estreno",$ASC=true){
		$this->load->model('Peliculas_model','pelis');
		if($ASC==TRUE) $ASC="ASC";
		else $ASC="DESC";
		$data['records']=$this->pelis->get_pelicules_genero($id_genero,$orderby,$ASC,$config['per_page']);
		$this->load->library('pagination');
		$this->load->library('table');
		//Configuramos los datos de la paginacion
		$config['base_url'] = 'http://localhost/credit_sintesi/peliculas/pelicula/';
		$config['total_rows'] = count($data['records']);
		$config['per_page']   = 20;
		//iniciamos la paginacion
		$this->pagination->initialize($config);
		$this->load->view('templates/header',$data);
		$this->load->view('peliculas/peliculas',$data);
		$this->load->view('templates/footer');
	}

	public function add_pelicula(){
		$this->load->helper("form");
		form_open_multipart('peliculas/add_pelicula');
		
	}
}
?>